package de.hmm.hwip.osgi;

import java.io.InputStream;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

import android.content.res.Resources;

public class InstallFromRActivator implements BundleActivator{

	private String fileRootPath="";
	private Resources res;
	
	public InstallFromRActivator(Resources res, String fileRootPath){
		this.res = res;
		this.fileRootPath = fileRootPath;
		System.out.println("fileRootPath = " + fileRootPath);
	}
	
	@Override
	public void start(BundleContext arg0) throws Exception {
		
        // get from R and install to apps private files dir
		
		InputStream is = res.openRawResource(R.raw.bundlerepository);
        Bundle bundlebundlerepository = arg0.installBundle(fileRootPath+"/bundle/bundlerepository.jar", is);
        
        is = res.openRawResource(R.raw.shell);
        Bundle bundleshell = arg0.installBundle(fileRootPath+"/bundle/shell.jar", is);
        
        
        is = res.openRawResource(R.raw.ipojo);
        Bundle bundleipojo = arg0.installBundle(fileRootPath+"/bundle/ipojo.jar", is);
        
        is = res.openRawResource(R.raw.ipojoannotations);
        Bundle bundleipojoannotations = arg0.installBundle(fileRootPath+"/bundle/ipojoannotations.jar", is);
        
        is = res.openRawResource(R.raw.ipojoarch);
        Bundle bundleipojoarch = arg0.installBundle(fileRootPath+"/bundle/ipojoarch.jar", is);
        
        is = res.openRawResource(R.raw.fileinstall130);
        Bundle bundlefileinstall130 = arg0.installBundle(fileRootPath+"/bundle/fileinstall130.jar", is);
        
        
        bundleshell.start();
        bundlebundlerepository.start();
        bundleipojo.start();
        bundleipojoannotations.start();
        bundleipojoarch.start();
        bundlefileinstall130.start();
		
	}

	@Override
	public void stop(BundleContext arg0) throws Exception {
		// TODO Auto-generated method stub
		
	}

	
}
